clear
est clear


	
	
	
	use "$input/full_geoid_pair_panel.dta"
	//Make sure only include states that have a storm in at least one county at least once in our sample years
		bysort state_fips: egen max=max(storm)
			drop if max!=1
			
			duplicates drop from_geoid, force
		
			rename from_geoid fips
			keep fips gdp
			g ln_gdp=ln(gdp)
			egen mean_gdp=mean(gdp)
			egen sd_gdp=sd(gdp)
			g gdp_z=(gdp-mean_gdp)/sd_gdp
			replace gdp2019=ln
			drop ln
			
			export delimited "$figdat/county_gdp.csv", replace
	clear	
	
	
	use "$input/full_geoid_pair_panel.dta"
		//Make sure only include states that have a storm in at least one county at least once in our sample years
		bysort state_fips: egen max=max(storm)
			drop if max!=1
		
		collapse (mean) migration ,by(to_geoid  storm )
		rename to_geoid fips
		preserve	
			keep if storm==0
			export delimited "$figdat/county_to_migration_nonstorm.csv", replace
		restore	
		
		preserve	
			keep if storm==1
			export delimited "$figdat/county_to_migration_storm.csv", replace
		restore
	clear
	
	use"$input/full_geoid_pair_panel_wind.dta"
	//Make sure only include states that have a storm in at least one county at least once in our sample years
		bysort state_fips: egen max=max(storm)
			drop if max!=1
			
			mvencode storm, mv(0) o
			bysort from_geoid: egen has_storm=max(storm)
			duplicates drop from_geoid, force
		
			rename from_geoid fips
			keep fips has_storm
			
			
			export delimited "$figdat/storm_sample_wind.csv", replace
	clear
	
	
	use"$input/full_geoid_pair_panel_flood.dta"
	//Make sure only include states that have a storm in at least one county at least once in our sample years
		bysort state_fips: egen max=max(storm)
			drop if max!=1
			
			mvencode storm, mv(0) o
			bysort from_geoid: egen has_storm=max(storm)
			duplicates drop from_geoid, force
		
			rename from_geoid fips
			keep fips has_storm
			
			
			export delimited "$figdat/storm_sample_flood.csv", replace
	clear
	
	
	